<?php
$propertyStr = Yii::t('BWeSport','Property');
$contentStr = Yii::t('BWeSport','Content');
$bookNameStr = Yii::t('BWeSport','BookName');
$bookAblePriceStr = Yii::t('BWeSport','BookAblePrice');
$BookUnitPriceStr = Yii::t('BWeSport','BookUnit price');
$priceStr = Yii::t('BWeSport','Price');
$yuanStr = Yii::t('BWeSport','Yuan');
$unitStr = Yii::t('BWeSport','Unit');
$courtTypeStr = Yii::t('BWeSport','Court Type');
$selectAreaStr = Yii::t('BWeSport','Select Area');
//添加预订项的名称
if (is_numeric($bookableId) && $bookableId > 0) {
    $theBookableId = $bookableId;
} else {
    $event = new BWEvent($eventId);
    $messageList = $event->getMessageManager()->getMessageList();
    $count = 0;
    if (is_array($messageList)) {
        $count = count($messageList);
    }
    $theBookableId = $count;
}
$event = new BWEvent($eventId);
$venderMessage = $event->getMessageManager()->getMessage('vender');
$bookableMessageField = 'message_bookable' . $theBookableId . '_vender';
$bookablePriceField = 'media_price_message_bookable';
//$bookablePriceUnitField = 'media_priceUnit_message_bookable';
$courtTypeField = 'media_courtType_message_bookable';
$regionField = 'media_region_message_bookable';
$model->addField($courtTypeField);
$model->addField($bookableMessageField);
$model->addField($bookablePriceField);
//$model->addField($bookablePriceUnitField);
$model->addField($regionField);

if ($bookableId > 0) {
    $bookableMessage = $venderMessage->getMessageManager()->getMessage('bookable' . $theBookableId);
    if ($bookableMessage instanceof BWMessage && $bookableMessage->getId() != NULL) {
        $model->$bookableMessageField = $bookableMessage->description;
        $model->$bookablePriceField = $bookableMessage->getMediaManager()->getMedia('price')->getContent();
        //$model->$bookablePriceUnitField = $bookableMessage->getMediaManager()->getMedia('priceUnit')->getContent();
        $courtType = $bookableMessage->getMediaManager()->getMedia('courtType');
        if ($courtType != NULL) {
            $model->$courtTypeField = $courtType->getContent();
        }
        $region = $bookableMessage->getMediaManager()->getMedia('region');
        if ($region != NULL) {
            $model->$regionField = $region->getContent();
        }
    }
}
?>
<table class="table table-hover">
    <colgroup>
        <col class="span3">
        <col class="span6">
    </colgroup>
    <thead>
        <tr>
            <th><?php echo $propertyStr; ?></th>
            <th><?php echo $contentStr; ?></th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>
                <?php echo '<nobr style="color: red;font-size:20px">*</nobr>',$bookNameStr; ?>
            </td>
            <td>
                <?php
                echo $form->textField($model, $bookableMessageField, array('placeholder' => $bookNameStr.'...', 'required' => true));
                ?>
            </td>
        </tr>
        <tr>
            <td>
                <?php echo '<nobr style="color: red;font-size:20px">*</nobr>',$bookAblePriceStr; ?>
            </td>
            <td>
                <div><?php echo $priceStr; ?>：
                    <?php
                    echo $form->textField($model, $bookablePriceField, array('placeholder' =>$BookUnitPriceStr.'...', 'required' => true));
                    ?>
                    <?php //echo $yuanStr;?>
                </div>
                <div><?php echo $unitStr;?>：
                    计价单位是 [元／每个场地*每个时间段]
                    <?php
                    //echo $form->dropDownList($model, $bookablePriceUnitField, BWTimeSlotType::getTimeUnitList());
                    ?>
                </div>
            </td>
        </tr>
        <tr>
            <td>
                <?php echo '<nobr style="color: red;font-size:20px">*</nobr>',$courtTypeStr; ?>
            </td>
            <td>
                <?php
                echo CHtml::activeDropDownList($model, $courtTypeField, Blyn::app()->getActiveApp()->getCourtTypeList());
                ?>
            </td>
        </tr>
        <tr>
            <td>
                <?php echo '<nobr style="color: red;font-size:20px">*</nobr>',$selectAreaStr; ?>
            </td>
            <td>
                <?php
                echo CHtml::activeDropDownList($model, $regionField, Blyn::app()->getActiveApp()->getRegionList('china.chongqing'));
                ?>
            </td>
        </tr>
    </tbody>
</table>